import threading
import requests

urls = [f"https://api.web.360kan.com/v1/rank?cat={i}" for i in range(1, 7)]


def worker(url):
    print(f"{threading.current_thread().name}开始干活")
    res = requests.get(url)
    print(res.json())
    print(f"{threading.current_thread().name}干活完毕")


def main():
    thre = []
    for i, url in enumerate(iterable=urls):
        t = threading.Thread(target=worker, args=(url,), name=f"work_{i}")
        t.start()
        thre.append(t)
    for t in thre:
        t.join()
    print("全部线程结束")


if __name__ == "__main__":
    main()
